/* Reset and base styles for iframe compatibility */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 100%);
    /* Dynamic height based on environment */
    height: 450px; /* Default for iframe */
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Adjust height for standalone browser tab */
@media (min-height: 500px) {
    body {
        height: 90vh;
    }
}

/* Main container with full width and height utilization */
.container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    position: relative;
}

/* Lyrics container with responsive layout */
.lyrics-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    max-width: 100%;
    padding: 10px;
}

/* Individual lyrics lines with flexible wrapping */
.lyrics-line {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: clamp(16px, 4vw, 24px);
    font-weight: bold;
    color: #2C3E50;
    line-height: 1.2;
}

/* Regular word styling */
.word {
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: default;
}

/* Image card container with 3D flip effect */
.image-card {
    perspective: 1000px;
    width: clamp(60px, 12vw, 80px);
    height: clamp(60px, 12vw, 80px);
    cursor: pointer;
    transition: transform 0.2s ease;
    /* Touch-friendly sizing for mobile */
    min-width: 44px;
    min-height: 44px;
}

/* Hover and active states for better interaction feedback */
.image-card:hover {
    transform: scale(1.05);
}

.image-card:active {
    transform: scale(0.95);
}

/* Inner card structure for flip animation */
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Flipped state */
.image-card.flipped .card-inner {
    transform: rotateY(180deg);
}

/* Front and back card faces */
.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Front face with image/emoji */
.card-front {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    border: 3px solid #FF6B6B;
}

/* Back face with revealed word */
.card-back {
    background: linear-gradient(135deg, #FF6B6B, #FF8E8E);
    color: white;
    transform: rotateY(180deg);
    border: 3px solid #FFD700;
}

/* Icon styling for visual elements */
.sun-icon, .emoji-icon, .sky-icon {
    font-size: clamp(24px, 6vw, 36px);
    animation: gentle-bounce 2s ease-in-out infinite;
}

/* Revealed word styling */
.revealed-word {
    font-size: clamp(12px, 3vw, 16px);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    word-break: break-word;
    padding: 2px;
}

/* Control panel for buttons */
.control-panel {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    max-width: 400px;
}

/* Button styling optimized for touch and text fitting */
.play-button, .reset-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    font-size: clamp(14px, 3.5vw, 18px);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    /* Ensure button width fits text content */
    white-space: nowrap;
    min-height: 44px; /* Touch-friendly minimum */
}

/* Play button specific styling */
.play-button {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.play-button:hover {
    background: linear-gradient(135deg, #45a049, #3d8b40);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.play-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Reset button specific styling */
.reset-button {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
}

.reset-button:hover {
    background: linear-gradient(135deg, #F57C00, #E65100);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.reset-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Instructions area */
.instructions {
    position: absolute;
    bottom: 5px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: clamp(10px, 2.5vw, 12px);
    color: #2C3E50;
    background: rgba(255, 255, 255, 0.8);
    padding: 4px 8px;
    border-radius: 15px;
    opacity: 0.8;
}

/* Gentle bounce animation for icons */
@keyframes gentle-bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-5px);
    }
    60% {
        transform: translateY(-3px);
    }
}

/* Responsive adjustments for mobile devices */
@media (max-width: 480px) {
    .lyrics-line {
        gap: 6px;
    }
    
    .control-panel {
        gap: 10px;
        margin-top: 10px;
    }
    
    .play-button, .reset-button {
        padding: 10px 16px;
        min-width: 120px;
    }
    
    .instructions {
        bottom: 2px;
        right: 5px;
        font-size: 10px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .word {
        background: white;
        border: 2px solid #000;
    }
    
    .card-front {
        border: 4px solid #000;
    }
    
    .card-back {
        border: 4px solid #000;
        background: #000;
        color: white;
    }
}